package pkg

import (
	"context"
	"github.com/qiniu/go-sdk/v7/storagev2/credentials"
	"github.com/qiniu/go-sdk/v7/storagev2/http_client"
	"github.com/qiniu/go-sdk/v7/storagev2/uploader"
	"mime/multipart"
	"poblish_house/api/app_config"
)

func QiNiuYun(file multipart.File) {
	accessKey := app_config.AppConf.QiNiuConfig.AK
	secretKey := app_config.AppConf.QiNiuConfig.SK
	mac := credentials.NewCredentials(accessKey, secretKey)

	bucket := "guoao1"

	uploadManager := uploader.NewUploadManager(&uploader.UploadManagerOptions{
		Options: http_client.Options{
			Credentials: mac,
		},
	})
	err := uploadManager.UploadReader(context.Background(), nil, &uploader.ObjectOptions{
		BucketName: bucket,
		CustomVars: map[string]string{
			"name": "github logo",
		},
	}, nil)
	if err != nil {
		return
	}
}
